﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Diagnostics;
using System.Data;

namespace MyClever.Lib
{
    public class RemotePluginLoader : MarshalByRefObject
    {
        private PluginBuilder pluginBuilder;

        public PluginBuilder PluginBuilder
        {
            get 
            {
                return this.pluginBuilder;
            }
        }

        /// <summary>
        /// Creates a remote assembly loader
        /// </summary>
        public RemotePluginLoader()
        {
            this.pluginBuilder = null;
        }

        /// <summary>
        /// This method use the builder-pattern to load the expected plugin, using the correct programming language instructions.
        /// </summary>
        public void Load(PluginPath pluginPath, string pluginClass, ProgrammingLanguage programmingLanguage)
        {
            if (ProgrammingLanguage.CSharp == programmingLanguage)
            {
                this.pluginBuilder = new CSharpPluginBuilder(pluginPath, pluginClass, programmingLanguage);
            }
            else if (ProgrammingLanguage.Python == programmingLanguage)
            {
                this.pluginBuilder = new PythonPluginBuilder(pluginPath, pluginClass, programmingLanguage);
            }
            Debug.Assert(null != this.pluginBuilder);

            PluginLoader pluginLoader = new PluginLoader(this.pluginBuilder);
        }
    }
}
